<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/static/js/layui/css/layui.css" media="all">
    <script type="text/javascript" src="/static/js/jquery/jquery-3.5.1.min.js"></script>
    <script type="text/javascript" src="/static/js/layui/layui.js"></script>
</head>
<body>
<div class="layui-tab layui-tab-brief">
    <div class="layui-col-md2 layui-col-md-offset1">
        <div class="layui-form-item">
            <label class="layui-form-label">名称：</label>
            <div class="layui-input-block">
                <input type="text" name="title" id="name" style="width: 200px; pointer-events: none;" lay-verify="title" autocomplete="off" placeholder="名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">价格：</label>
            <div class="layui-input-block">
                <input type="text" name="title" id="price" style="width: 200px;" lay-verify="title" autocomplete="off" placeholder="价格" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">库存：</label>
            <div class="layui-input-block">
                <input type="text" name="title" id="number" style="width: 200px;" lay-verify="title" autocomplete="off" placeholder="库存" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">历史总量：</label>
            <div class="layui-input-block">
                <input type="text" name="title" id="totalNumber" style="width: 200px;" lay-verify="title" autocomplete="off" placeholder="历史总量" class="layui-input">
            </div>
        </div>
        <div style="width: 320px; text-align: center">
            <div class="layui-btn-container">
                <button type="button" id="btn" class="layui-btn layui-btn-lg layui-btn-radius layui-btn-normal">确认修改</button>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        requestdata();
        function requestdata(){
            var data = parent.data;
            // console.log(data);
            $("#name").val(data.lingjian.name);
            $("#price").val(data.lingjian.price);
            $("#number").val(data.lingjian.number);
            $("#totalNumber").val(data.lingjian.totalNumber);
            $("#btn").val(data.lingjian.id);
        }
        $("#btn").click(function(){
            var param = {"id":$("#btn").val(),"name":$("#name").val(),"price":$("#price").val(),"number":$("#number").val(),"totalNumber":$("#totalNumber").val()}
            // console.log(param);
            $.ajax({
                url:"/main/warehouse/update/lingjianupdate",
                data:param,
                dataType:"json",
                success:function (data){
                    console.log(data);
                    if (data==1){
                        layer.msg("修改成功");
                        setTimeout(function (){
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index);
                        },1500);
                    }else {
                        layer.msg("修改失败");
                    }
                }
            })
        });
    });
</script>
</body>
</html>